package com.example.zk2_lx.adapter;

import android.view.View;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.example.zk2_lx.R;
import com.example.zk2_lx.entity.VideoEntity;
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer;

import java.util.List;

public class VideoAdapter extends BaseMultiItemQuickAdapter<VideoEntity.DataBean, BaseViewHolder> {
    public VideoAdapter(@Nullable List<VideoEntity.DataBean> data) {
        super(data);
        addItemType(0, R.layout.item_video_nomral);
        addItemType(1, R.layout.item_video_nomral);
        addItemType(2, R.layout.item_video_full);
        addItemType(5, R.layout.item_video_nomral);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder holder, VideoEntity.DataBean bean) {
        switch (bean.getItemType()){
            case 0:
            case 1:
            case 2:
            case 5:
                StandardGSYVideoPlayer gsy = holder.findView(R.id.gsy);
                gsy.setUp(bean.getVideopath(),true,"");
                gsy.startPlayLogic();

                //实现横屏观看
                gsy.setAutoFullWithSize(false);
                gsy.setLockLand(true);
                gsy.setShowFullAnimation(true);
                ImageView iv = holder.findView(R.id.iv_dianzan);
                if(bean.getDianzan()==1){
                    iv.setImageResource(R.mipmap.ic_launcher_round);
                }else{
                    iv.setImageResource(R.mipmap.ic_launcher);
                }
                break;

        }
    }
}
